//
//  AbsentViewController.m
//  PCSchool
//
//  Created by Arindam Ghosh on 7/12/13.
//  Copyright (c) 2013 Jayanta. All rights reserved.
//

#import "AbsentViewController.h"

@interface AbsentViewController ()

@end

@implementation AbsentViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

-(void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    NSLog(@"%@",NSStringFromClass(self.class));
    self.studentArray = [NSMutableArray array];
    
    [self.studentArray addObject:@"Adam 1"];
    [self.studentArray addObject:@"Adam 2"];
    [self.studentArray addObject:@"Adam 3"];
    [self.studentArray addObject:@"Adam 4"];
    [self.studentArray addObject:@"Adam 5"];
    [self.studentArray addObject:@"Adam 6"];
    [self.studentArray addObject:@"Adam 7"];
    [self.studentArray addObject:@"Adam 8"];
    [self.studentArray addObject:@"Adam 9"];
    [self.studentArray addObject:@"Adam 10"];
    [self.studentArray addObject:@"Adam 11"];
    [self.studentArray addObject:@"Adam 12"];
    [self.studentArray addObject:@"Adam 13"];
    [self.studentArray addObject:@"Adam 14"];
    [self.studentArray addObject:@"Adam 15"];
    
    self.absentDetailsArray = [NSMutableArray array];
    
    
    
    
}

- (void)viewDidAppear:(BOOL)animated {
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
    [self.leftPanelTableView selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionBottom];
}


#pragma mark - TableView Delegates & Datasource

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        
        return 46.0;
    }
    if (tableView.tag == 102) {
        
        return 50.0;
    }
    return 0.0;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        
    }
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 101) {
        return [self.studentArray count];
        
    }
    if (tableView.tag == 102) {
        return 10;
        
    }
    
    return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 101) {
        
        static NSString *CellIdentifier = @"StudenListCell";
        StudenListCell * cell =(StudenListCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        if (!cell) {
            
            cell =(StudenListCell*)[BaseTableCell cellFromNibNamed:CellIdentifier];
            
        }
        
        [self configureCell:cell atIndexPath:indexPath];
        
        return cell;
    }
    if (tableView.tag == 102) {
        
        static NSString *CellIdentifier = @"AbsentTableCell";
        AbsentTableCell * cell =(AbsentTableCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        if (!cell) {
            
            cell =(AbsentTableCell*)[BaseTableCell cellFromNibNamed:CellIdentifier];
            
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        [self configureCell2:cell atIndexPath:indexPath];
        
        
        
        return cell;
    }
    
    return nil;
    
}


-(void)configureCell:(StudenListCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    cell.cellTextLabel.text = [self.studentArray objectAtIndex:indexPath.row];
}


-(void)configureCell2:(AbsentTableCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    //cell.cellLeftLabel.text = [self.studentArray objectAtIndex:indexPath.row];
}



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark - Button Action

- (IBAction)proximityButtonAction:(id)sender
{
    UIButton *btn = (UIButton *)sender;
    
    int selectedIndex = btn.selected ? 0 : 1;
    
    btn.selected = selectedIndex;
}

- (IBAction)seeCodeButtonAction:(id)sender
{
    
}


#pragma mark - Memory CleanUp

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_baseImageView release];
    [_rightPanelImageView release];
    [_leftPanelView release];
    [_leftPanelImageView release];
    [_leftPanelTableView release];
    [_searchBarImgView release];
    [_searchBarTextField release];
    [_proximityButton release];
    [_searchBarLeftimageView release];
    [_rightPanelTableView release];
    [_rightPanelheaderImageView release];
    [_rightPanelView release];
    
    [_rightPanelHighlightedImageView release];
    [_rightPanelDateLabel release];
    [_rightPanelReasonLabel release];
    [_rightPanelCodeLabel release];
    
    [_codeButton release];

    [super dealloc];
}

@end
